<?
		$link = "pages/nhom-dia-diem".$type;//duyệt
		$link1 = "pages/ket-qua-tim-kiem-what".$type;//duyệt
		$link2 = "pages/ket-qua-tim-kiem-nhom-where".$type;//duyệt
		$link3 = "pages/ket-qua-tim-kiem-what-quan-huyen".$type;//duyệt
		$link4 = "pages/ket-qua-tim-kiem-nhom-duong".$type;//duyệt
		$link5 = "pages/ket-qua-tim-kiem-what-duong".$type;//duyệt
		$link6 = "pages/ket-qua-tim-kiem-duong".$type;//duyệt
		$link7 = "pages/ket-qua-tim-kiem-quan-tinh".$type;
		
		include("model/xl_tim_dich_vu_dia_diem.php");
		include("model/xl_dia_diem.php");
		include("model/xl_binh_luan_dia_diem.php");
		include("model/xl_hinh_anh_dia_diem.php");
		include("model/xl_dia_diem_chinh_sua.php");
		
		$xl_dia_diem = new xl_dia_diem();
		$xl_binh_luan = new xl_binh_luan_dia_diem();
		$xl_hinh_anh = new xl_hinh_anh_dia_diem();
		$xl_tim_kiem =new xl_tim_dich_vu_dia_diem();
		$xl_dia_diem_chinh_sua=new xl_dia_diem_chinh_sua();
		
		$id;
		$name;
		$what;
		$idwhat;
		$where;
		$idwhere;
		$tinh;
		$idtinh;
		$quan;
		$idquan;
		$duong;
		$sl;
		
		$what=$_REQUEST['what'];
		$where=$_REQUEST['where'];
		$idwhat=$_REQUEST['idwhat'];
		$idwhere=$_REQUEST['idwhere'];
		
		$arrDiaDiemMoiCapNhat=$xl_dia_diem_chinh_sua->danhSachDiaDiemMoiChinhSua();
		
		if(($what!=""&&$where=="")||($what==""&&$where!="")||($what!=""&&$where!=""))
		{
			$tktinh=$xl_tim_kiem->timKiemTinhThanh($idwhere);
			$sl=count($tktinh);
			if($where!=""){
				
				$arrWhere=explode(" - ",$where);
				if(count($arrWhere)==2)
				{
					$quan=$arrWhere[0];
					$tinh=$arrWhere[1];
					$idquan=$idwhere;
					$idtinh=0;
				}
				else 
				{
					if($sl>0){
						$tinh=$where;
						$idtinh=$idwhere;
						$idquan=0;
					}
					else
						$duong=$where;
					
				}
				
			}
			
			if($what!="")
			{
				//$dttk=$xl_tim_kiem->danhSachNhom($idwhat);
				if($idwhat!="")//count($dttk)>0)
				{
					$id=$idwhat;
					$name=$what;
					if($idwhere==""){
						// === 1. what = nhóm địa điểm + where = null
						if($where=="")
						{
							$total_place = count($xl_dia_diem->tongDiaDiem($id));
							$arrDDFirst = $xl_dia_diem->dsDiaDiemTheoNhom_ViewMore_First($id);
							$arrDiaDiemMoiCapNhat = $xl_dia_diem->dsDiaDiemMoiCapNhat($id);
							include $link;
						}
						else
						{
							// == 5. what= nhóm địa điểm + where = đường
							if($duong!="")
							{
								$total_place = count($xl_tim_kiem->tongTimKiemNhomDuong($duong,$id));
								$arrDDFirst = $xl_tim_kiem->danhSachTimKiemNhomDuong_first($duong,$id);
								include $link4;
							}
						}
					}
					else
					{
						// == 2. what= nhóm địa điểm + where = quận tỉnh
						$total_place = count($xl_tim_kiem->tongTimKiemNhomWhere($idquan,$idtinh,$id));
						$arrDDFirst = $xl_tim_kiem->danhSachTimKiemNhomWhere_first($idquan,$idtinh,$id);
						include $link2;
					}
					
				}
				else
				{
					if($idwhere=="")
					{
						if($where=="")
						{
							//== 3. what= tên địa điểm + where = null
							$arrKq=$xl_tim_kiem->danhSachTimKiemWhat_first($what);
							$total_place = $xl_tim_kiem->tongTimKiemWhat($what);
							include $link1;
						}
						else
						{
							//== 6. what=tên địa điểm + where = đường
							if($duong!="")
							{
								$arrKq=$xl_tim_kiem->danhSachTimKiemWhatDuong_first($duong,$what);
								$total_place = $xl_tim_kiem->tongTimKiemWhatDuong($duong,$what);
								include $link5;
							}
						}
					}
					else
					{
						//== 4. what = tên địa điểm + where = quận tỉnh	
						$total_place = $xl_tim_kiem->tongTimKiem_What_Quan_Huyen($what,$idquan,$idtinh);
						$arrKq = $xl_tim_kiem->danhSachTimKiem_What_Quan_Huyen_first($what,$idquan,$idtinh);
						include $link3;		
					}
				}
			}
			else
			{
				// ==7. what = null + where = đường
				if($duong !="")
				{
					$total_place = $xl_tim_kiem->tongTimKiemDuong($duong);
					$arrKq = $xl_tim_kiem->danhSachTimKiemDuong_first($duong);
					include $link6;	
				}
				else
				{
					// ==8. what = null + where = quận+tỉnh
					$total_place = $xl_tim_kiem->tongTimKiemQuanTinh($idquan,$idtinh);
					$arrKq = $xl_tim_kiem->danhSachTimKiemQuanTinh_first($idquan,$idtinh);
					include $link7;	
				}
			}
		}
		
		

?>